<template>
    <div>
        <el-table :data="rolelist" border style="width: 100%">
            <el-table-column prop="id" label="角色编号" align="center">
            </el-table-column>
            <el-table-column prop="rolename" label="角色名称" align="center">
            </el-table-column>
            <el-table-column prop="status" label="状态" align="center" >
                <template slot-scope="item">
                    <!-- item.row 代表的是table中的每一行数据 -->
                    <div>
                        <!-- {{item.row}} -->
                        <!-- {{ item.row.status == 1 ? "启用" : "禁用" }} -->
                        <el-tag v-if="item.row.status == 1" type="success">启用 </el-tag>
                        <el-tag type="danger" v-else> 禁用</el-tag>
                    </div>
                </template>
            </el-table-column>
            <el-table-column prop="set" label="操作" align="center">
                <template slot-scope="item">
                    <el-button type="primary" icon="el-icon-edit" @click="edit(item.row.id)" circle></el-button>
                    <el-button type="danger" icon="el-icon-delete" @click="del(item.row.id)" circle></el-button>
                </template>

            </el-table-column>
        </el-table>
    </div>
</template>

<script>
import { roledelete } from '../../request/app'
import { mapGetters, mapActions } from 'vuex'
export default {
    data() {
        return {

        };
    },
    computed: {
        ...mapGetters({
            rolelist: 'setpeople/getlist',
            getlist: 'setshop/getstatemenulist'
        })
    },
    mounted() {
        if (this.getlist.length == 0) {
            // console.log(1111111111111);
            this.ACgetlist()
        }
        console.log(this.rolelist);
        this.ACgetlistpeo()
    },
    methods: {
        ...mapActions({
            ACgetlist: 'setshop/ACgetlist',
            ACgetlistpeo: 'setpeople/ACgetlistpeo'
        }),
        edit(id){
            this.$emit('peoedit',id)
        },
        del(id) {
            // console.log(id);

            roledelete({
                id
            })
                .then(res => {
                    // console.log(res);
                    this.ACgetlistpeo()
                })
        }
    },
    components: {
    },
}
</script>

<style scoped>
</style>
